package com.lzy.pattern.iterator.userdefined;

import java.util.ArrayList;
import java.util.List;

/**
 * @ClassName: StudentAggregateImpl
 * @Description: 具体聚合（ConcreteAggregate）角色：实现抽象聚合类，返回一个具体迭代器的实例。
 * @Author: LiuZy
 * @Date: 2022/5/1 19:41
 * @Version: 1.0
 */
public class StudentAggregateImpl implements StudentAggregate{

    private List<Student> studentList;

    public StudentAggregateImpl(){
        studentList = new ArrayList<>();
    }

    @Override
    public void add(Student student) {
        studentList.add(student);
    }

    @Override
    public void remove(Student student) {
        studentList.remove(student);
    }

    @Override
    public StudentIterator getStudentIterator() {
        return new StudentIteratorImpl(studentList);
    }
}